package com.ruoyi.web.controller.system;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.Register;
import com.ruoyi.system.service.IRegisterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 档案查阅管理功能Controller
 * 
 * @author zzr
 * @date 2025-01-06
 */
@RestController
@RequestMapping("/system/register")
public class RegisterController extends BaseController
{
    @Autowired
    private IRegisterService registerService;

    /**
     * 查询档案查阅管理功能列表
     */
    //@PreAuthorize("@ss.hasPermi('system:register:list')")
    @GetMapping("/list")
    public TableDataInfo list(Register register)
    {
        startPage();
        List<Register> list = registerService.selectRegisterList(register);
        return getDataTable(list);
    }

    /**
     * 导出档案查阅管理功能列表
     */
    //@PreAuthorize("@ss.hasPermi('system:register:export')")
    @Log(title = "档案查阅管理功能", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Register register)
    {
        List<Register> list = registerService.selectRegisterList(register);
        ExcelUtil<Register> util = new ExcelUtil<Register>(Register.class);
        util.exportExcel(response, list, "档案查阅管理功能数据");
    }

    /**
     * 获取档案查阅管理功能详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:register:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(registerService.selectRegisterById(id));
    }

    /**
     * 新增档案查阅管理功能
     */
    //@PreAuthorize("@ss.hasPermi('system:register:add')")
    @Log(title = "档案查阅管理功能", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Register register)
    {
        return toAjax(registerService.insertRegister(register));
    }

    /**
     * 修改档案查阅管理功能
     */
    //@PreAuthorize("@ss.hasPermi('system:register:edit')")
    @Log(title = "档案查阅管理功能", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Register register)
    {
        return toAjax(registerService.updateRegister(register));
    }

    /**
     * 删除档案查阅管理功能
     */
    //@PreAuthorize("@ss.hasPermi('system:register:remove')")
    @Log(title = "档案查阅管理功能", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(registerService.deleteRegisterByIds(ids));
    }


    @GetMapping("/sumPeople")
    public int sumPeople() {
        System.out.println(registerService.selectSumPeople());
        return registerService.selectSumPeople();
    }
    @GetMapping("/sumVolume")
    public int sumVolume() {
        System.out.println(registerService.selectSumVolume());
        return registerService.selectSumVolume();
    }
}
